package com.ohuang.myapp.slice;

import com.ohuang.baseapp.utils.ToastUtils;
import com.ohuang.myapp.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.Text;
import ohos.agp.components.webengine.WebView;

public class WebAbilitySlice extends AbilitySlice {
    private WebView webView;
    String url = "http://www.baidu.com";

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_web);
        webView = (WebView) findComponentById(ResourceTable.Id_webView);
        Text text= (Text) findComponentById(ResourceTable.Id_text);

        if (intent != null) {
            url = intent.getStringParam("url");
        }
        text.setText(url);

        getUITaskDispatcher().delayDispatch(new Runnable() {
            @Override
            public void run() {
                    if (webView!=null) {
                        webView.load(url);
                    }
            }
        },1000);


    }

    @Override
    public void onActive() {
        super.onActive();

    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
